package com.theeviljames;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.StringTokenizer;

public class Level3 {

	private static final String rootpath = "D:\\Program Files\\eclipse\\PC\\workspace\\RandomStuff\\nuggets\\";
	public static void main(String[] args) {
		
		try {
			BufferedReader br = new BufferedReader(new FileReader(new File(rootpath + "25820.txt")));
			String s = br.readLine();
			while(s!=null){
				System.out.println(s);
				String next = "";
				/*for(char c:s.toCharArray()){
					if(48<=c&&c<=57){
						next+=Character.toString(c);
					}
				}*/
				
				StringTokenizer st = new StringTokenizer(s," ");
				boolean foundnext = false;
				while(st.hasMoreTokens()&&!foundnext){
					String t = st.nextToken();
					int counter = 0;
					for(char c:t.toCharArray()){
						if(!(48<=c&&c<=57)){
							break;
						}
						counter++;
					}
					if(counter==t.length()){
						foundnext = true;
						next = t;
					}
				}
				if(next=="")break;
				br = new BufferedReader(new FileReader(new File(rootpath + next + ".txt")));
				System.out.println("Next file " + next);
				s = br.readLine();
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
}
